import request from '../../utils/request'

Page({
    data:{
        videoGroupList:[],
        navId:"",
        videoList:[]
    },
    onLoad(){
        this.getVideoGroupList()
   
        
    },
    // 获取导航栏标签信息
    async getVideoGroupList(){
        let videoGroupListData = await request('/video/group/list')
      
        this.setData({
            videoGroupList:videoGroupListData.data.data.slice(0,14),
            navId:videoGroupListData.data.data[0].id
        })

        this.getVideoList(this.data.navId)
    },
    // 修改当前选中导航栏
    changeNav(event){
        console.log(event.currentTarget.id);
        let navId = event.currentTarget.id
        this.setData({
            navId:navId>>>0
        })
    },
    // 获取默认/选中导航栏的内容信息
    async getVideoList(navId){
        let videoListData = await request('/video/group',{id:navId})
        // console.log(videoListData.data.datas);
        // console.log(videoListData.data.datas[0].data.urlInfo.url); //视频链接地址
        let index = 0
        let videoList = videoListData.data.datas.map(item=>{
            item.id = index++
            return item
        })
        this.setData({
            videoList
        })
        console.log(this.data.videoList);
    }
})